import store from '@/store'

export default {
  install: function(Vue) {
    Vue.directive('errorImg', {
      inserted: function(el, obj) {
        if (!el.src) {
          el.src = obj.value
        }
        el.onerror = function() {
          el.src = obj.value
        }
      }
    })
    Vue.directive('arrow', {
      inserted(el, binding) {
        const points = store.state.user.userInfo.roles.points
        if (!points.includes(binding.value)) {
          // 隐藏
          el.parentNode.removeChild(el)
        }
      }
    })
  }
}
